import 'package:flutter/material.dart';

// 我的
class My extends StatefulWidget {
  const My({Key? key}) : super(key: key);

  @override
  State<My> createState() => _MyState();
}

class _MyState extends State<My> {
//  功能列表集合
  var operationList = [
    {"name": "我的店铺"},
    {"name": "收货中心"},
    {"name": "帮助中心"},
    {"name": "测试中心"},
  ];

  Map<String, dynamic> message = {"account": "kk", "phone": "18798988888"};

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
          child: Column(
        children: [_my, _operation],
      )),
    );
  }

  Widget get _my {
    return Column(
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Flex(
              direction: Axis.horizontal,
              children: [
                const SizedBox(height: 5),
                // Expanded(
                // child: Container(
                Container(
                  width: 90,
                  height: 90,
                  margin: const EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(50),
                      image: const DecorationImage(
                          image: NetworkImage(
                              "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202107%2F26%2F20210726133405_da67d.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1649840075&t=2795f6a899f181dc251fb86bee0a7255"),
                          fit: BoxFit.fill)),
                ),
                Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      "用户名：" + message["account"],
                      style: const TextStyle(
                        fontSize: 18,
                      ),
                    ),
                    Text(
                      "手机号：" + message["phone"],
                      style: const TextStyle(
                        fontSize: 18,
                      ),
                    )
                  ],
                )
              ],
            )
          ],
        )
      ],
    );
  }

  //
  Widget get _operation {
    return Container(
        child: Column(
      children: operationList.map((Map map) {
        return Container(
            width: double.infinity,
            height: 80,
            margin: const EdgeInsets.all(0),
            child: Column(
              children: [
                Row(
                  // 排序顺序
                  textDirection: TextDirection.ltr,
                  // 开始方向 若mainAxisSize为min则没有意义
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  // mainAxisSize: MainAxisSize.min,
                  // 纵轴默认居中
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    const Expanded(
                      child: Icon(Icons.remove_red_eye),
                      flex: 1,
                    ),
                    const SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      child: Text(
                        map["name"],
                        style: const TextStyle(
                          fontSize: 26,
                          // fontWeight: FontWeight.bold,
                        ),
                        textAlign: TextAlign.left,
                      ),
                      flex: 4,
                    ),
                    Expanded(
                      child: IconButton(
                          onPressed: () {
                            // print(map);
                            if (map["name"] == "帮助中心"){
                              Navigator.of(context).pushNamed("login");
                            }else if(map["name"] == "测试中心"){
                              Navigator.of(context).pushNamed("test",arguments: {"title": "测试中心"});
                            }
                          },
                          icon: const Icon(Icons.chevron_right)),
                      flex: 1,
                    ),
                  ],
                ),
                const SizedBox(
                  width: double.infinity,
                  height: 5,
                ),
                const Divider(
                  height: 1.0,
                  indent: 0.0,
                  color: Colors.grey,
                )
              ],
            ));
      }).toList(),
    ));
  }
}
